import Vue from 'vue'
import Login from './Login.vue'
import router from './login.router'
import axios from '../../http'
import {Message,Loading} from 'element-ui'
import 'element-ui/lib/theme-chalk/index.css';
import { cheeToken } from '../../utils/ssoCheckToken';
import utils from '../../utils/utils';
import ElementUI from 'element-ui';
Vue.use(ElementUI);
Vue.config.productionTip = false
//这样可以在各个组件中使用axios
Vue.prototype.$axios=axios;
const checToken = cheeToken();
checToken.then(data => {
  if (data == "invalid") {
    //debugger
    console.log("data===invaLid")
    new Vue({
      router,
      //store,
      render: h => h(Login)
    }).$mount('#login')
   
    //跑到首页
    //window.location.href=document.location.protocol+"//"+window.location.host
    //window.location.href = utils.delUrlParams(window.location.href);
  } else {
    var hasRePath=null;
    if(hasRePath=utils.getUrlKey("redirect")){
      console.log('hasRePath='+hasRePath)

      if (hasRePath.indexOf("/ready") != -1) {
        hasRePath=utils.getUrl(hasRePath);
     } 

      var domain=null;
      if(domain=utils.getUrl(hasRePath)){
        console.log('domain='+domain)
        //window.location.href = domain+'ready?token='+
        //localStorage.getItem('token')+'&redirect='+hasRePath ;
        window.location.href =hasRePath;
      
      }
    }else{
      window.location.href = "http://www.sso.com/" ;
    }
    //如果有效跳转ready   再跳转redirect页面
  }
})
